package com.kuang.dao;

import com.kuang.pojo.Blog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface BlogMapper {

//    插入数据
    @Insert("insert into mybatis.blog(id,title,author,create_time,views)\n" +
            "            values (#{id},#{title},#{author},#{create_time},#{views});")
    int addBlog(Blog blog);

    //查询数据
    @Select("select * from mybatis.blog where 1=1\n" +
            "            <if test=\"title!=null\">\n" +
            "                and title =#{title}\n" +
            "            </if>\n" +
            "            <if test=\"author!=null\">\n" +
            "                and author =#{author}\n" +
            "            </if>")
    List<Blog> queryBlogIF(Map map);

}
